#include <iostream>
#include <cstring>
using namespace std;

void replaceSpaces(char str[], int length)
{
    int numSpace = 0;
    int newLength = 0;
    for (int i = 0; str[i] != '\0'; i++)
    {
        if (str[i] == ' ')
        {
            numSpace++;
        }
    }
    newLength = length - numSpace + 3*numSpace;
    for (int i = length -1; i >= 0; i--)
    {
        if (str[i] != ' ')
        {
            str[--newLength] = str[i];
        }
        else
        {
            str[--newLength] = '0';
            str[--newLength] = '2';
            str[--newLength] = '%';
        }
    }
}

int main()
{
    char str[256] = "123 123 ";
    replaceSpaces(str, strlen(str));
    cout << str << endl;
}